home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / box / MotionBlur.rx < prev    next >
Text File  |  2000-10-31  |  2KB  |  145 lines

  1. /*     arexx Script 
  2.     Motion Blur
  3. */
  4.  
  5.     call addlib("rexxmathlib.library", 5, -30, 0)
  6.  
  7.     options results
  8.     parse ARG Port x1 y1 x2 y2 b
  9.  
  10.     ADDRESS COMMAND
  11.  
  12.     Length=40
  13.     Angle=0
  14.     Mix=50
  15.     Dec=1
  16.  
  17.     IF EXISTS('PerfectPaint:Prefs/Rexx_Prefs/MotionBlur') THEN DO
  18.         IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/MotionBlur', "R") then DO
  19.             Length= READLN('lfile')
  20.             Angle= READLN('lfile')
  21.             Mix= READLN('lfile')
  22.             Dec= READLN('lfile')            
  23.             CALL CLOSE('lfile')
  24.         END
  25.     END
  26.     
  27.     ADDRESS value Port
  28.  
  29.     pp_GetDepth
  30.     D=result
  31.     IF D<24 then DO
  32.         pp_Warn 'This*script*is*only|for*24bits*Picture.'    
  33.         pp_PermitRefresh
  34.         Exit
  35.     END
  36.  
  37.     W=x2-x1+1
  38.     H=y2-y1+1
  39.  
  40.     pp_DialogInit 250 115 "*Motion*Blur*" 4
  41.         pp_Integer 0 140 5 50 16 "Length*(5-60)" 1 Length
  42.         pp_Integer 1 140 25 50 16 "Angle*(0-359)" 1 Angle
  43.         pp_Integer 2 140 45 50 16 "Mix*value*(1-100)" 1 Mix
  44.         pp_Integer 3 140 65 50 16 "Mix*decrement*(0-50)" 1 Dec
  45.     pp_Dialog
  46.     rc=result
  47.     if rc=0 then
  48.         do
  49.             EXIT
  50.         end
  51.  
  52.     pp_GetDialog 0
  53.     Length=result
  54.  
  55.     pp_GetDialog 1
  56.     Angle=result
  57.     
  58.     pp_GetDialog 2
  59.     Mix=result
  60.  
  61.     pp_GetDialog 3
  62.     Dec=result            
  63.  
  64.     CALL SavePrefs('MotionBlur',Length,Angle,Mix,Dec)
  65.     ADDRESS value Port
  66.  
  67.     if Angle=90|Angle=270 then Angle=Angle+1
  68.     Rads=Angle*(3.14149/180)
  69.  
  70.     if Length>50 then Mix=Length
  71.     
  72.     pp_StencilStat
  73.     Stencil=result
  74.  
  75.     pp_PicttoSpare
  76.     pp_SpareOnOff    
  77.  
  78.     if Stencil=1 then DO
  79.         pp_StencilOff
  80.     END
  81.  
  82.     pp_PickBrush x1 y1 W H
  83.  
  84.     pp_GetWidthB
  85.     IF result=0 THEN DO
  86.         pp_Warn 'Not*enough*memory.'
  87.         EXIT
  88.     END    
  89.  
  90.     if Stencil=0 then DO
  91.         pp_UpdateUndo
  92.     END
  93.  
  94.     Do i=Length*2 to 2 by -2
  95.         X=trunc(sqrt(power(i,2)/(1+power(abs(tan(Rads)),2))))
  96.         Y=trunc(sqrt(power(i,2)-power(x,2)))
  97.  
  98.         if Angle>90 & Angle<270 then X=-X
  99.         if Angle>0 & Angle<180 then Y=-Y
  100.  
  101.         pp_BrushOpacity Mix
  102.         pp_Plot x1+X+W/2 y1+Y+H/2
  103.  
  104.         Mix=Mix-Dec
  105.     END
  106.  
  107.     IF Stencil=1 then DO
  108.         pp_StencilOn
  109.     END
  110.  
  111.     pp_FreeBrush
  112.  
  113.     Mix=100-TRUNC((2/5)*Length+6)
  114.     pp_SpareOnOff
  115.     pp_ComposeReqOff
  116.     pp_UpdateUndoBox x1 y1 x2 y2    
  117.     pp_EffectOn
  118.     pp_Spare
  119.     pp_Compose 0 Mix 0
  120.     pp_Boxf x1 y1 x2 y2
  121.     pp_EffectOff
  122.     pp_ComposeReqOn
  123.  
  124. EXIT
  125.  
  126. SavePrefs: PROCEDURE
  127.     
  128.     Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  129.  
  130.     if EXISTS(Prefname) THEN DO
  131.         ADDRESS COMMAND
  132.         'delete >nil: '||Prefname
  133.     END
  134.  
  135.     IF OPEN('pfile',PrefName,'W') THEN DO
  136.  
  137.     do i=2 to ARG()
  138.         CALL WRITELN('pfile',ARG(i))
  139.     end
  140.  
  141.     CALL CLOSE('pfile')
  142.  
  143. RETURN
  144.  
  145.